package com.zjmzxfzhl.integrityconstraint.entity;

import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 业务完整性验证实体jdbc方式的转换类
 *
 * @author 庄金明
 */
public class IntegrityConstraintRowMapper implements RowMapper<IntegrityConstraint> {
    @Override
    public IntegrityConstraint mapRow(ResultSet resultSet, int i) throws SQLException {
        IntegrityConstraint integrityConstraint = IntegrityConstraint.builder().build();
        integrityConstraint.setBusinessKey(resultSet.getString("businessKey"));
        integrityConstraint.setVerifyType(resultSet.getString("verifyType"));
        integrityConstraint.setJsonData(resultSet.getString("jsonData"));
        integrityConstraint.setCreateTime(resultSet.getLong("createTime"));
        Long expire = resultSet.getLong("expire");
        integrityConstraint.setExpire(expire > 0 ? expire : -1L);
        return integrityConstraint;
    }
}
